package com.ruoyi.web.controller.construction.supertube;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.zhuangxiumain.orderformMain.OrderMaster;
import com.ruoyi.system.domain.zhuangxiumain.shopMain.ProductInfo;
import com.ruoyi.system.domain.zhuangxiumain.shopMain.SupplierInfo;
import com.ruoyi.system.service.zhaungxiuservice.shopService.OrderMasterService;
import com.ruoyi.system.service.zhaungxiuservice.shopService.ProductInfoService;
import com.ruoyi.system.service.zhaungxiuservice.shopService.SupplierInfoService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "超管商品店铺接口", tags = {"超管商品店铺接口"})
@RestController
@RequestMapping("/super/goodsstore")
public class SuperGoodsSupplierController extends BaseController {

    @Autowired
    private SupplierInfoService supplierInfoService;



    @PreAuthorize("@ss.hasPermi('super:goodsstore:list')")
    @GetMapping("/list")
    public TableDataInfo list(SupplierInfo supplierInfo)
    {
        startPage();
        List<SupplierInfo> list = supplierInfoService.supeSuppListAll(supplierInfo);
        return getDataTable(list);
    }

    /**
     * 导出供应商信息列表
     */
    @PreAuthorize("@ss.hasPermi('super:goodsstore:export')")
    @Log(title = "供应商信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SupplierInfo supplierInfo)
    {
        List<SupplierInfo> list = supplierInfoService.supeSuppListAll(supplierInfo);
        ExcelUtil<SupplierInfo> util = new ExcelUtil<SupplierInfo>(SupplierInfo.class);
        return util.exportExcel(list, "info");
    }

    /**
     * 获取供应商信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('super:goodsstore:query')")
    @GetMapping(value = "/{supplierId}")
    public AjaxResult getInfo(@PathVariable("supplierId") Integer supplierId)
    {
        return AjaxResult.success(supplierInfoService.supeSuppListAllById(supplierId));
    }
    /**
     * 状态修改
     */
    @PreAuthorize("@ss.hasPermi('super:goodsstore:edit')")
    @Log(title = "店铺管理", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody SupplierInfo supplierInfo)
    {
        return toAjax(supplierInfoService.changeSuperStatus(supplierInfo));
    }




    @Autowired
    private ProductInfoService productInfoService;


    @PreAuthorize("@ss.hasPermi('super:goodsstore:changeauditStatus')")
    @Log(title = "商品状态", businessType = BusinessType.UPDATE)
    @PutMapping("/changeauditStatus")
    public AjaxResult changeauditStatus(@RequestBody ProductInfo productInfo)
    {
        return toAjax(productInfoService.changeauditStatus(productInfo));
    }


    @PreAuthorize("@ss.hasPermi('super:goodsstore:superProductList')")
    @GetMapping("/superProductList")
    public TableDataInfo superProductList(ProductInfo productInfo)
    {
        startPage();
        List<ProductInfo> list = productInfoService.superProductList(productInfo);
        return getDataTable(list);
    }


    @PreAuthorize("@ss.hasPermi('super:goodsstore:productquery')")
    @GetMapping(value = "/productqueryById/{productId}")
    public AjaxResult ProductInfoById(@PathVariable("productId") Integer productId)
    {
        return AjaxResult.success(productInfoService.shangpinById(productId));
    }






    @PreAuthorize("@ss.hasPermi('super:goodsstore:superProexport')")
    @Log(title = "商品信息", businessType = BusinessType.EXPORT)
    @GetMapping("/superProexport")
    public AjaxResult superProexport(ProductInfo productInfo)
    {
        List<ProductInfo> list1 = productInfoService.superProductList(productInfo);
        ExcelUtil<ProductInfo> util = new ExcelUtil<ProductInfo>(ProductInfo.class);
        return util.exportExcel(list1, "info");
    }



    @Autowired
    private OrderMasterService orderMasterService;

    @PreAuthorize("@ss.hasPermi('super:goodsstore:superOrderMasterList')")
    @Log(title = "订单信息", businessType = BusinessType.EXPORT)
    @GetMapping("/superOrderMasterList")
    public TableDataInfo superOrderMasterList(OrderMaster orderMaster)
    {
        startPage();
        Integer productIdone = orderMaster.getProductIdone();
        System.err.println("**************************************************"+productIdone);
        orderMaster.setProductId(productIdone);
        List<OrderMaster> list = orderMasterService.superOrderMasterList(orderMaster);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('super:goodsstore:superOrderxport')")
    @Log(title = "订单导出信息", businessType = BusinessType.EXPORT)
    @GetMapping("/superOrderxport")
    public AjaxResult superOrderxport(OrderMaster orderMaster)
    {
        List<OrderMaster> list1 = orderMasterService.superOrderMasterList(orderMaster);
        ExcelUtil<OrderMaster> util = new ExcelUtil<OrderMaster>(OrderMaster.class);
        return util.exportExcel(list1, "info");
    }

}
